﻿using ExamDemo.Models;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Web;

namespace ExamDemo.Data
{
        //初始化数据
        public class SayDemoDbInitlizer : DropCreateDatabaseAlways<SayDb>
        {
            protected override void Seed(SayDb db)
            {
                //向Users模型插入数据
                db.Users.Add(new Users
                {
                    Username = "UU",
                    Password = "123456",
                    CreatedAt = DateTime.Now,
                    UpdatedAt = DateTime.Now,
                    Version = 0

                });
                //向Users模型插入数据
                db.Users.Add(new Users
                {
                    Username = "admin",
                    Password = "123456",
                    CreatedAt = DateTime.Now,
                    UpdatedAt = DateTime.Now,
                    Version = 0
                });
                //向Messages模型插入数据
                db.Messages.Add(new Messages
                {
                    FromUserId = 1,
                    Content = "今天好大的雨",
                    CreatedAt = DateTime.Now,
                    UpdatedAt = DateTime.Now,
                    Version = 0
                });
                //向Messages模型插入数据
                db.Messages.Add(new Messages
                {
                    FromUserId = 2,
                    Content = "我不是药神",
                    CreatedAt = DateTime.Now,
                    UpdatedAt = DateTime.Now,
                    Version = 0
                });
                //向Comments模型插入数据
                db.Comments.Add(new Comments
                {
                    MsgId = 1,
                    FromUserId = 2,
                    Content = "hello",
                    CreatedAt = DateTime.Now,
                    UpdatedAt = DateTime.Now,
                    Version = 0
                });
                //向Comments模型插入数据
                db.Comments.Add(new Comments
                {
                    MsgId = 2,
                    FromUserId = 1,
                    Content = "那你是谁",
                    CreatedAt = DateTime.Now,
                    UpdatedAt = DateTime.Now,
                    Version = 0
                });

                db.SaveChanges();
                base.Seed(db);
            }
        }
        }
